package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.Dao.Impl.CompanyDaoImpl;
import com.ysd.Dao.Impl.NewsClassIficationDaoImpl;
import com.ysd.Dao.Impl.NewsDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.News;
import com.ysd.entity.NewsClassiIfication;
public class NewsDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			//调用新闻类别实现类的方法
				NewsClassIficationDaoImpl nicDao = new NewsClassIficationDaoImpl();
				List<NewsClassiIfication> nic = nicDao.grtNewsFenLeiList();
				request.setAttribute("nic", nic);
			//通过新闻id获取指定新闻id的数据	
				int nId = Integer.parseInt(request.getParameter("newsId"));//接收前台传来的参数
				NewsDaoImpl niDao = new NewsDaoImpl();
				News ni = niDao.getNewsById(nId);
				request.setAttribute("ni", ni);//通过指定新闻id获取新闻内容
			//通过当前新闻id查询上一条新闻数据
				List<News> nNews = niDao.getNewsNext(nId);
				List<News> bNews = niDao.getNewsBefore(nId);
				request.setAttribute("nNews", nNews);//通过指定新闻id获取下一条新闻内容
				request.setAttribute("bNews", bNews);//通过指定新闻id获取上一条新闻内容
				
		request.getRequestDispatcher("article_list_content.jsp").forward(request, response);
	
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
